<?php
class  Somi_Models_News extends Zend_Db_Table_Abstract 
{
	protected $_name='news';
	protected $_primary = 'news_id';
	#protected $_rowClass = 'user';
	protected $_sequence  = true;
    
    public function getAll(){   	
    	#$db= Zend_Registry::get('db');
    	#$select = $db->select()->from('news');
    	#$select->from('news');
    	#$erg = $db->fetchAll($select);
    	$erg = $this->fetchAll();
    	return $erg;
    }

    public function getNews($id){	
    	$erg=$this->fetchRow('news_id="'.$id.'"'); 	
    	return $erg;
    }
    
    
    public function update($daten,$id){
    	$db= Zend_Registry::get('db');
    	$db->beginTransaction();
    	try{
    	$db->update('news',$daten,'news_id="'.$id.'"');
    	$db->commit();
    	}catch(Exception $e){
    		$db->rollBack();
    	}    	
    }
    
	public function insert($daten){
    	$db= Zend_Registry::get('db');
    	$db->beginTransaction();
    	try{
    	$db->insert('news',$daten);
    	$db->commit();
    	}catch(Exception $e){
    		$db->rollBack();
    	}   	
    }
    
	public function delete($id){
    	$db= Zend_Registry::get('db');
    	$db->beginTransaction();
    	try{
    	$db->delete('news','news_id="'.$id.'"');
    	$db->commit();
    	}catch(Exception $e){
    		$db->rollBack();
    	}   	
    }  
	
}

?>